//
//  TotalDetailViewController.m
//  BOSS-SOOC
//
//  Created by apple on 16/9/5.
//  Copyright © 2016年 Gcx. All rights reserved.
//
#define orige [self getColor:@"ff8a00"]


#import "TotalDetailViewController.h"
#import "TotalModel.h"
#import "MMLabel.h"
#import "TotalDetailTableView.h"
#import "SignDetailViewController.h"

@interface TotalDetailViewController ()<TotalDetailTableViewDelegate>{

    MMLabel *_titleLabel;
    MMLabel *_timeLabel;
    MMLabel *_numberLabel;
}

@end

@interface TotalDetailViewController (){

    TotalModel *_myModel;
}

@end

@implementation TotalDetailViewController

- (void)viewDidLoad{
    
    [super viewDidLoad];
    
    [self setNavBarTitle:@"统计详情"];
    
    [self creatUI];
}

- (void)creatUI{

    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, SIZEWIDTH, ScaleSize(207))];
    
    topView.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:topView];
    
    self.view.backgroundColor = BGC;
    
    _titleLabel = [[MMLabel alloc]initWithFrame:CGRectMake(ScaleSize(42), ScaleSize(42), SIZEWIDTH - 70 - ScaleSize(84), 20)];
    _titleLabel.textColor = Color333333;
    _titleLabel.font = NormalFont(42);
    
    _timeLabel = [[MMLabel alloc]initWithFrame:CGRectMake(ScaleSize(42), CGRectGetMaxY(_titleLabel.frame)+ScaleSize(33), 150, 20)];
    _timeLabel.textColor = Color999999;
    _timeLabel.font = NormalFont(42);
    
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(SIZEWIDTH - 70, ScaleSize(42), 65, 20)];
    lable.textColor = Color333333;
    lable.font = NormalFont(36);
    lable.textAlignment = NSTextAlignmentCenter;
    lable.text = @"点名次数";
    
    _numberLabel = [[MMLabel alloc]initWithFrame:CGRectMake(SIZEWIDTH - 70, ScaleSize(75)+15, 65, 20)];
    _numberLabel.textColor = orige;
    _numberLabel.font = NormalFont(42);
    _numberLabel.textAlignment = NSTextAlignmentCenter;
    
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(SIZEWIDTH - 70, ScaleSize(30), 0.5, ScaleSize(147))];
    view.backgroundColor = colordbdbdb;
    
    _numberLabel.text = _myModel.qdcs;
    _titleLabel.text = _myModel.kcmc;
    _timeLabel.text = _myModel.skxq;

    [topView addSubview:_timeLabel];
    [topView addSubview:_titleLabel];
    [topView addSubview:lable];
    [topView addSubview:_numberLabel];
    [topView addSubview:view];
    
    TotalDetailTableView *detail = [[TotalDetailTableView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(topView.frame)+9, SIZEWIDTH, SIZEHEIGHT - 73) style:UITableViewStyleGrouped];

    detail.kcid = _myModel.kcid;
    detail.sc_delegate = self;
    [self.view addSubview:detail];
}

//时间戳转换

-(UIColor *)getColor:(NSString *)hexColor {
    unsigned int red,green,blue;
    NSRange range;
    range.length = 2;
    
    range.location = 0;
    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];
    
    range.location = 2;
    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];
    
    range.location = 4;
    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];
    
    return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green / 255.0f) blue:(float)(blue / 255.0f) alpha:1.0f];
}

- (instancetype)getTotalModel:(TotalModel *)model{

    _myModel = model;

    
    return self;
}

#pragma mark -- 点击方法
- (void)tableView:(TotalDetailTableView *)tableView didSelectModel:(DianmingModel *)model{

    SignDetailViewController *vc = [[SignDetailViewController alloc]getKtid:model.ktid andPzqd:model.pzqd];
    
    vc.hidesBottomBarWhenPushed = YES;
    
    [self navigationCanDragBack:YES];
    
    [self.navigationController pushViewController:vc animated:YES];
}

@end
